<template lang="html">
<div class="icons">
    <swiper>
      <!-- slides -->
      <swiper-slide  v-for="(page,index) of pages" :key="index">
          <div v-for="item of page" class="icon" :key="item.id">
              <div class="icon-img">
                  <img class="icon-img-content" :src="item.imgUrl" alt="">
              </div>
              <p class="icon-desc">
                      {{item.desc}}
              </p>
          </div>
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>


</div>
</template>

<script>
export default {
	name: 'HomeIcons',
	data() {
		return {
			swiperOption: {
				autoplay: false
			}
		}
	},
	props: {
		iconList: Array
	},

	computed: {
		pages() {
			const pages = []
			this.iconList.forEach((item, index) => {
				const page = Math.floor(index / 8)
				if (!pages[page]) {
					pages[page] = []
				}
				pages[page].push(item)
			})
			return pages
		}
	}
}
</script>

<style lang="scss" scoped>
@import '~scss/varibles';
@import '~scss/mixins';
.icons /deep/ .swiper-container {
    height: 0;
    padding-bottom: 50%;
}
.icons {
    width: 100%;
    overflow: hidden;
    height: 0;
    padding-bottom: 50%;
    margin-top: 0.1rem;
    .icon {
        float: left;
        width: 25%;
        padding-bottom: 25%;
        overflow: hidden;
        position: relative;
        height: 0;
        .icon-img {
            position: absolute;
            box-sizing: border-box;
            padding: 0.1rem;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0.44rem;
            .icon-img-content {
                height: 100%;
                display: block;
                margin: 0 auto;
            }

        }
        .icon-desc {
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            height: 0.44rem;
            line-height: 0.44rem;
            color: $dartTextColor;
            text-align: center;
            @include ellipsis;

        }

    }

}
</style>
